<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');


//用户模型
class User_model extends CI_Model{

	const TBL_USER = 'user';
    #查询用户
    public function list_user(){
        $query = $this->db->get(self::TBL_USER);
        return $query->result_array();
    }
    #更新
    public function update($data,$user_id){
        $condition['user_id'] = $user_id;
        return $this->db->where($condition)->update(self::TBL_USER,$data);
    }

    #获取商品信息
    public function get_user($user_id){
        $condition['user_id'] = $user_id;
        $query = $this->db->where($condition)->get(self::TBL_USER);
        return $query->row_array();
    }

    #删除
    public function delete($user_id){
        $condition['user_id'] = $user_id;
        $query = $this->db->where($condition)->delete(self::TBL_USER);
        if ($query && $this->db->affected_rows() > 0) {
            # code...
            return true;
        } else {
            # code...
            return false;
        }
    }

    #获取总的记录数
    public function count_user(){
        return $this->db->count_all_results(self::TBL_USER);
    }

}